package com.usian.admin.config

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
open class XxlJobConfig {
    @Value("\${xxljob.admin.addresses}")
    private lateinit var adminAddresses: String

    @Value("\${xxljob.executor.appname}")
    private lateinit var appName: String

    @Value("\${xxljob.executor.port}")
    private val port = 0

    @Bean
    open fun xxlJobExecutor() : XxlJobSpringExecutor = XxlJobSpringExecutor().apply {
        setAdminAddresses(adminAddresses)
        setAppName(appName)
        setPort(port)
        setLogRetentionDays(30)
    }
}